package com.chenfeng.ego.rest.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.chenfeng.ego.commons.pojo.BigPic;
import com.chenfeng.ego.mapper.TbContentMapper;
import com.chenfeng.ego.pojo.TbContent;
import com.chenfeng.ego.pojo.TbContentExample;
import com.chenfeng.ego.rest.service.ShowPicService;
@Service
public class ShowPicServiceImpl implements ShowPicService
{

	@Resource
	TbContentMapper contentMapper;
	@Value("${categoryId}")
	private long categoryId ;
	@Override
	//将大图片放到集合中
	public List<BigPic> showPic()
	{
		List<BigPic> pic = new ArrayList<>();
		TbContentExample example = new TbContentExample();
		example.createCriteria().andCategoryIdEqualTo(categoryId);
		List<TbContent> contents = this.contentMapper.selectByExample(example);
		for (TbContent tbContent : contents)
		{
			BigPic big = new BigPic();
			big.setSrc(tbContent.getPic());
			big.setSrcB(tbContent.getPic2());
			big.setAlt("对不起图片加载失败");
			big.setHeight(240);
			big.setWidth(240);
			big.setWidthB(670);
			big.setHref(tbContent.getUrl());
			pic.add(big);
		}
		return pic;
	}	
}
